package com.snowRemovingUser.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.snowRemovingUser.domain.TWeatherSynopsis;
import com.snowRemovingUser.service.ITWeatherSynopsisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 天气概要Controller
 * 
 * @author lg
 * @date 2024-04-11
 */
@RestController
@RequestMapping("/snowRemoving/synopsis")
public class TWeatherSynopsisController extends BaseController
{
    @Autowired
    private ITWeatherSynopsisService tWeatherSynopsisService;

    /**
     * 查询天气概要列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:list')")
    @GetMapping("/list")
    public TableDataInfo list(TWeatherSynopsis tWeatherSynopsis)
    {
        startPage();
        List<TWeatherSynopsis> list = tWeatherSynopsisService.selectTWeatherSynopsisList(tWeatherSynopsis);
        return getDataTable(list);
    }

    /**
     * 导出天气概要列表
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:export')")
    @Log(title = "天气概要", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWeatherSynopsis tWeatherSynopsis)
    {
        List<TWeatherSynopsis> list = tWeatherSynopsisService.selectTWeatherSynopsisList(tWeatherSynopsis);
        ExcelUtil<TWeatherSynopsis> util = new ExcelUtil<TWeatherSynopsis>(TWeatherSynopsis.class);
        util.exportExcel(response, list, "天气概要数据");
    }

    /**
     * 获取天气概要详细信息
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tWeatherSynopsisService.selectTWeatherSynopsisById(id));
    }

    /**
     * 新增天气概要
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:add')")
    @Log(title = "天气概要", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TWeatherSynopsis tWeatherSynopsis)
    {
        return toAjax(tWeatherSynopsisService.insertTWeatherSynopsis(tWeatherSynopsis));
    }

    /**
     * 修改天气概要
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:edit')")
    @Log(title = "天气概要", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TWeatherSynopsis tWeatherSynopsis)
    {
        return toAjax(tWeatherSynopsisService.updateTWeatherSynopsis(tWeatherSynopsis));
    }

    /**
     * 删除天气概要
     */
    @PreAuthorize("@ss.hasPermi('snowRemoving:synopsis:remove')")
    @Log(title = "天气概要", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tWeatherSynopsisService.deleteTWeatherSynopsisByIds(ids));
    }
}
